package com.pp.web.controller;


import com.pp.api.order.OrderInfoService;
import com.pp.common.anno.ArgsValidate;
import com.pp.common.bean.ResultBuilder;
import com.pp.common.bean.ResultObject;
import com.pp.common.constant.RequestConsts;
import com.pp.web.service.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

@RestController
public class MyBatisTestController {

    @Autowired
    UserServiceImpl userService;

    @Autowired
    OrderInfoService orderInfoService;

    @RequestMapping("test")
    @ArgsValidate(value = RequestConsts.TEST_ARGS)
    public ResultObject test(@RequestBody Map param) throws Exception {
        Integer size = (Integer) param.get("size");
        Integer num = (Integer)param.get("num");
        Integer id = (Integer) param.get("id");
        return ResultBuilder.success(userService.userIPage(id,num,size));
    }

    @RequestMapping("order")
    public ResultObject orderTest(){
        Map map = new HashMap();
        map.put("id", 1);
        return ResultBuilder.success(orderInfoService.queryOrderInfo(map));
    }

    @RequestMapping("date")
    public LocalDateTime dateTest(){
        return LocalDateTime.now();
    }

}
